<template>
  <div style="margin-left: 10px">
    <svg
      width="11"
      height="10"
      viewBox="0 0 11 10"
      fill="none"
      xmlns="http://www.w3.org/2000/svg"
    >
      <rect
        x="0.501953"
        y="5"
        width="7.07011"
        height="7.07011"
        transform="rotate(-45 0.501953 5)"
        fill="#3A8FFF"
      />
    </svg>
    <span style="white-space: nowrap;margin-left: 10px">参考数据情况</span>
  </div>
  <div class="box">
    <div class="box-left">
      <mpie4 :xdata="piedata"/>
    </div>
    <div class="box-left">
      <mbar4 :xdata="barlist" />
    </div>
    <div class="box-left">
      <mbar5 :xdata="cksjdy"  />
    </div>
  </div>
</template>

<script setup>
import {ref,onMounted} from "vue";
import mpie4 from './charts/mpie4.vue'
import mbar4 from './charts/mbar4.vue'
import mbar5 from './charts/mbar5.vue'
import {GETdataStandardSetcount120Two,GETdataStandardSetcountDataValueReferenceTwo,
  GETdataStandardSetcountDwMeasureValueMK0103004Two} from '@/api/DAtastandard.js'
const cksjdy = ref({
  xdata: [],
  ydata: [],
  ydata2: []
})
const barlist = ref({
  xdata: [],
  ydata: [],
})
const piedata = ref([])
onMounted(() => {
  GETdataStandardSetcount120Two().then(res => {
    let arr = []
    let arr2 = []
    res.data.forEach(item => {
      arr.push(item.name)
      arr2.push(item.value)
    })
    barlist.value.xdata = arr
    barlist.value.ydata = arr2
  }).catch(err => {
    barlist.value.xdata = ['类型一', '类型二', '类型三', '类型四']
    barlist.value.ydata = [335, 451, 612, 322, 633, 673, 422, 454, 500]
  })
  Promise.all([GETdataStandardSetcountDwMeasureValueMK0103004Two(),GETdataStandardSetcount120Two()
  ]).then(([metadataRes, count18Res]) =>{
    let arr = []
    let arr1 = []
    let arr2 = []
    let arr3 = []
    count18Res.data.forEach(item => {
      arr.push(item.name)
      arr1.push(item.value)
      let obj = {}
      obj.name = item.name
      obj.value = item.value
      arr3.push(obj)
    })
    cksjdy.value.xdata = arr
    cksjdy.value.ydata = arr1
    piedata.value = arr3
    metadataRes.data.forEach(item => {
      arr2.push(item.value)
    })
  }).catch(err=>{
    cksjdy.value.xdata = ['类型一', '类型二', '类型三', '类型四']
    cksjdy.value.ydata = [335, 451, 612, 322, 633, 673, 422, 454, 500]
    cksjdy.value.ydata2 = [231, 244, 523, 212, 444, 231, 543, 454, 543]
    piedata.value = [
        { value: 5301, name: '项目', },
        { value: 2205, name: '人员',  },
        { value: 1032, name: '企业',  }
      ]
  })
})
</script>

<style lang="scss" scoped>
.box{
  display: flex;
}
.box-left {
  flex: 1;
  height: 200px;
}
</style>